Skip to content

gh-144835: Added missing explanations for some parameters in glob and iglob.#144836

Merged
facundobatista merged 9 commits into
python:mainfrom
facundobatista:improve-globglob-docstrings
Mar 2, 2026
Merged

gh-144835: Added missing explanations for some parameters in glob and iglob.#144836
facundobatista merged 9 commits into
python:mainfrom
facundobatista:improve-globglob-docstrings

Conversation

@facundobatista

@facundobatista facundobatista commented Feb 15, 2026

Copy link
Copy Markdown
Member

I took the explanations for the missing parameters from the documentation itself (slightly edited for brevity) for the cases of root_dir and dir_fd in both glob and iglob.

For the case of iglob's include_hidden, I just copied it from glob.

Comment thread Lib/glob.py Outdated
Comment thread Lib/glob.py Outdated
Comment thread Lib/glob.py Outdated
Comment on lines +28 to +34
If root_dir is not None, it should be a path-like object specifying the
root directory for searching. It has the same effect as changing the
current directory before calling it. If pathname is relative, the
result will contain paths relative to root_dir.

If dir_fd is not None, it should be a file descriptor referring to a
directory, and paths will then be relative to that directory.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If root_dir is not None, it should be a path-like object specifying the
root directory for searching. It has the same effect as changing the
current directory before calling it. If pathname is relative, the
result will contain paths relative to root_dir.
If dir_fd is not None, it should be a file descriptor referring to a
directory, and paths will then be relative to that directory.
If `root_dir` is not None, it should be a path-like object specifying the
root directory for searching. It has the same effect as changing the
current directory before calling it. If `pathname` is relative, the
result will contain paths relative to root_dir.
If `dir_fd` is not None, it should be a file descriptor referring to a
directory, and paths will then be relative to that directory.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wary of "It has the same effect as changing the current directory before calling it" phrasing as we don't want anyone to think that the process wide global cwd is changed by these API calls. I think it may be better to state what the default behavior is when not specified or None. ie "if not specified or None, the search will be conducted from the processes current working directory and returned paths will be relative to that" (Q: is that accurate?)

@terryjreedy terryjreedy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with Hugo's suggestions, and yes, backport.

@bedevere-app

bedevere-app Bot commented Feb 15, 2026

Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

@terryjreedy terryjreedy added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Feb 15, 2026
@facundobatista

Copy link
Copy Markdown
Member Author

@hugovk @terryjreedy I have made the requested changes; please review again, thanks!!

@bedevere-app

bedevere-app Bot commented Feb 18, 2026

Copy link
Copy Markdown

Thanks for making the requested changes!

@terryjreedy: please review the changes made to this pull request.

@bedevere-app bedevere-app Bot requested a review from terryjreedy February 18, 2026 14:20
@facundobatista

Copy link
Copy Markdown
Member Author

I'm wary of "It has the same effect as changing the current directory before calling it" phrasing as we don't want anyone to think that the process wide global cwd is changed by these API calls. I think it may be better to state what the default behavior is when not specified or None. ie "if not specified or None, the search will be conducted from the processes current working directory and returned paths will be relative to that" (Q: is that accurate?)

@gpshead I understand your concern. I'm using the same wording that in the glob documentation.

Maybe we can improve both? I prefer the "positive description" (indicate what it does, not what it doesn't). What about the following clarification?

    If `root_dir` is not None, it should be a path-like object specifying 
    the root directory for searching. It has the same effect as changing 
    the current directory before calling it (without actually 
    changing it). If pathname is relative, the result will contain 
    paths relative to `root_dir`.

Thanks!

@facundobatista

Copy link
Copy Markdown
Member Author

@hugovk @terryjreedy @gpshead hey! let me know please if you need something else is needed before I go forward with merging this. Thanks!

Comment thread Lib/glob.py Outdated
@facundobatista

Copy link
Copy Markdown
Member Author

@gpshead thanks!

@facundobatista facundobatista merged commit e542255 into python:main Mar 2, 2026
50 of 51 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @facundobatista for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 2, 2026
…ob and iglob. (pythonGH-144836)

* Added missing explanations for some parameters in glob and iglob.

* News entry.

* Added proper 'func' indication in News file.

* Consistent use of backticks.

* Improved wording.

* consistent wording between the two docstrings

---------
(cherry picked from commit e542255)

Co-authored-by: Facundo Batista <facundo@taniquetil.com.ar>
Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 2, 2026
…ob and iglob. (pythonGH-144836)

* Added missing explanations for some parameters in glob and iglob.

* News entry.

* Added proper 'func' indication in News file.

* Consistent use of backticks.

* Improved wording.

* consistent wording between the two docstrings

---------
(cherry picked from commit e542255)

Co-authored-by: Facundo Batista <facundo@taniquetil.com.ar>
Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
@bedevere-app

bedevere-app Bot commented Mar 2, 2026

Copy link
Copy Markdown

GH-145415 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Mar 2, 2026
@bedevere-app

bedevere-app Bot commented Mar 2, 2026

Copy link
Copy Markdown

GH-145416 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Mar 2, 2026
hugovk pushed a commit that referenced this pull request Mar 2, 2026
…lob and iglob. (GH-144836) (#145415)

Co-authored-by: Facundo Batista <facundo@taniquetil.com.ar>
Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
hugovk pushed a commit that referenced this pull request Mar 2, 2026
…lob and iglob. (GH-144836) (#145416)

Co-authored-by: Facundo Batista <facundo@taniquetil.com.ar>
Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
…ob and iglob. (python#144836)

* Added missing explanations for some parameters in glob and iglob.

* News entry.

* Added proper 'func' indication in News file.

* Consistent use of backticks.

* Improved wording.

* consistent wording between the two docstrings

---------

Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants